package com.itheima.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.itheima.domain.db.UserInfo;
import com.itheima.domain.mongo.RecommendUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class RecommendUserInfoVo {

    //设置主键类型为用户输入
    @TableId(type = IdType.INPUT)
    private Long id; //用户id
    private String nickname; //昵称
    private String avatar; //用户头像
    private String gender; //性别
    private String[] tags; //用户标签：多个用逗号分隔
    private Integer age; //年龄
    private Long fateValue; //缘分值

    public static RecommendUserInfoVo init(UserInfo userInfo, RecommendUser recommendUser){
        RecommendUserInfoVo vo = new RecommendUserInfoVo();
        BeanUtils.copyProperties(userInfo,vo);
        if (userInfo.getTags()!=null){
            vo.setTags(userInfo.getTags().split(","));
        }
        vo.setFateValue(recommendUser.getScore().longValue());
        return  vo;
    }


}
